﻿<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="java.io.*,java.util.*,java.sql.*"%>
<%@ page import="com.techbirds.ms.model.UserDto"%>
<%@ page import="org.apache.ibatis.io.Resources" %>
<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="org.apache.ibatis.session.SqlSessionFactory" %>
<%@ page import="org.apache.ibatis.session.SqlSessionFactoryBuilder" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%!private static SqlSessionFactory sqlSessionFactory;%>
<%!private static Reader reader; %>

<%

out.println("Hello World");


String resource = "conf.xml";
reader = Resources.getResourceAsReader("conf.xml");
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
SqlSession session2 = sqlSessionFactory.openSession();
/**
 * 映射sql的标识字符串，
 * me.gacl.mapping.userMapper是userMapper.xml文件中mapper标签的namespace属性的值，
 * getUser是select标签的id属性值，通过select标签的id属性值就可以找到要执行的SQL
 */
String statement = "com.techbirds.ms.dao.UserDtoMapper.selectByPrimaryKey";//映射sql的标识字符串
//执行查询返回一个唯一user对象的sql

UserDto user = session2.selectOne (statement,1);  
out.println("Hello World"+user.getName());

%>
</body>
</html>